<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:if test="${param.v=='3.0'}">
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <jsp:include page="../../head.jsp"/>
    </head>
    <body>
</c:if>
<style type="text/css">
    table#declarationTable table {
        border: 0;
        margin: 0;
        border-collapse: collapse;
        border-spacing: 0;
        width: 100%;
    }

    table#declarationTable {
        border: 0;
        margin: 0;
        border-collapse: collapse;
        border-spacing: 0;
        width: 100%;
    }

    table#declarationTable th, table#declarationTable td {
        border: 1px solid;
        padding: 0;
    }
</style>
<script type="text/javascript">
    $(function () {
//        var gross_weight_val = Math.ceil($("#gross_weight").text());
//        var net_weight_val = Math.ceil($("#net_weight").text());
//        $("#gross_weight").text(gross_weight_val);
//        $("#net_weight").text(net_weight_val);
       var container_no = $("#container_no").text();
        container_no = container_no.split(",");
        var d = "";
        for (var i = 0; i < container_no.length; i++) {
            d += container_no[i] + ",";
            if (i % 8 == 7) {
                d = d.substring(0, d.length - 1) + "<br>";
            }
        }
        $("#container_no").html("集装箱号<br>" + d.substring(0, d.length - 1));
    });

    function changeTrColor(obj) {
        var _table = obj.parentNode;
        for (var i = 0; i < _table.rows.length; i++) {
            _table.rows[i].style.backgroundColor = "";
        }
//        obj.style.backgroundColor = "blue";
    }


</script>
<table id="declarationTable">
    <caption><h3>中华人民共和国海关<c:choose><c:when
            test="${declare.declaration_type eq 'I'}">进口</c:when><c:otherwise>出口</c:otherwise></c:choose>货物报关单</h3>
    </caption>
    <tbody>
    <tr>
        <td>收发货人(${declare.company_co})<br/>${declare.company_name}</td>
        <td><c:choose><c:when
                test="${declare.declaration_type eq 'I'}">进口</c:when><c:otherwise>出口</c:otherwise></c:choose>口岸(${declare.export_port_code})<br/>${declare.export_port}</td>
        <td><c:choose><c:when
                test="${declare.declaration_type eq 'I'}">进口</c:when><c:otherwise>出口</c:otherwise></c:choose>日期<br/><c:if test="${not empty declare.export_date}"><fmt:formatDate
                value="${declare.export_date}" pattern="yyyy-MM-dd"/></c:if></td>
        <td>申报日期<br/><c:if test="${not empty declare.report_date}"><fmt:formatDate
                value="${declare.report_date}" pattern="yyyy-MM-dd"/></c:if></td>
    </tr>
    <tr>
        <td><c:choose><c:when
                test="${declare.declaration_type eq 'I'}">消费使用单位</c:when><c:otherwise>生产销售单位</c:otherwise></c:choose>(${declare.fahuo_company_co})<br/>${declare.fahuo_company_name}
        </td>
        <td colspan="3">
            <table>
                <tr>
                    <td style="border: 0;border-right: 1px solid;">
                        运输方式<br/>${declare.transport_mode}
                    </td>
                    <td style="border: 0;border-right: 1px solid;">
                        运输工具名称<br/>${declare.transport_na}<c:if test="${not empty declare.voyage_no}">/${declare.voyage_no}</c:if>
                    </td>
                    <td style="border: 0;">提运单号<br/>${declare.bl_no}</td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>申报单位(${declare.shenbao_company_co})<br/>${declare.shenbao_company_name}</td>
        <td>监管方式(${declare.trade_mode_code})<br/>${declare.trade_mode}</td>
        <td>征免性质(${declare.levymode_code})<br/>${declare.levymode}</td>
        <!-- 			<td> -->
        <%-- 				结汇方式<br/><s:property value="declare.lc_type"/> --%>
        <!-- 			</td> -->
        <td>备案号<br/>${declare.record_id}</td>
    </tr>
    <tr>
        <td colspan="4">
            <table>
                <tr>

                    <td style="border: 0;border-right: 1px solid;">
                        贸易国(地区)(${declare.trading_country_code})<br/>${declare.trading_country}
                    </td>
                    <td style="border: 0;border-right: 1px solid;">
                        <c:choose><c:when
                                test="${declare.declaration_type eq 'I'}">启运国(地区)</c:when><c:otherwise>运抵国(地区)</c:otherwise></c:choose>
                        (${declare.arrived_country_code})<br/>${declare.arrived_country}
                    </td>
                    <td style="border: 0;border-right: 1px solid;">
                        <c:choose><c:when
                                test="${declare.declaration_type eq 'I'}">装货港</c:when><c:otherwise>指运港</c:otherwise></c:choose>
                        (${declare.arrived_port_code})<br/>${declare.arrived_port}
                    </td>
                    <td style="border: 0;border-right: 1px solid;">
                        <c:choose><c:when
                                test="${declare.declaration_type eq 'I'}">境内目的地</c:when><c:otherwise>境内货源地</c:otherwise></c:choose>
                        (${declare.goods_addr_code})<br/>${declare.goods_addr}
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td colspan="4">
            <table>
                <tr>
                    <%-- 						<td style="border: 0;border-right: 1px solid;">批准文号<br/>${declare.approval_no}</td> --%>
                    <td style="border: 0;border-right: 1px solid;">许可证号<br/>${declare.license_no}
                    </td>
                    <td style="border: 0;border-right: 1px solid;">成交方式<br/>${declare.deal_mode}
                    </td>
                    <td style="border: 0;border-right: 1px solid;">运费
                        <br/>
                        <c:choose>
                            <c:when test="${not empty declare.freight1 && not empty declare.freight2}">
                                ${declare.freight1} / ${declare.freight2} / ${declare.freight3} /
                            </c:when>
                            <c:otherwise>///</c:otherwise>
                        </c:choose>
                    </td>
                    <td style="border: 0;border-right: 1px solid;">保费
                        <br/>
                        <c:choose>
                            <c:when test="${not empty declare.premium1 && not empty declare.premium2}">
                                ${declare.premium1} / ${declare.premium2} / ${declare.premium3} /
                            </c:when>
                            <c:otherwise>///</c:otherwise>
                        </c:choose>
                    </td>
                    <td style="border: 0;">杂费
                        <br/>
                        <c:choose>
                            <c:when test="${not empty declare.otherfee1 && not empty declare.otherfee2}">
                                ${declare.otherfee1} / ${declare.otherfee2} / ${declare.otherfee3} /
                            </c:when>
                            <c:otherwise>///</c:otherwise>
                        </c:choose>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td colspan="4">
            <table>
                <tr>
                    <td style="border: 0;border-right: 1px solid;">合同协议号<br/>${declare.contract_no}
                    </td>
                    <td style="border: 0;border-right: 1px solid;">件数<br/>${declare.goods_count}
                    </td>
                    <td style="border: 0;border-right: 1px solid;">包装种类<br/>${declare.goods_package}
                    </td>
                    <td style="border: 0;border-right: 1px solid;">毛重(千克)<br/>
                        <label id="gross_weight">
                            ${declare.gross_weight}
                        </label>
                    </td>
                    <td style="border: 0;">净重(千克)<br/>
                        <label id="net_weight">
                            ${declare.net_weight}
                        </label>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td colspan="4">
            <table>
                <tr>
                    <td id="container_no" style="border: 0;border-right: 1px solid;">
                        <c:forEach var="container" items="${declare.declaContainers}" varStatus="i">
                            ${container.containerNo}/<c:choose><c:when test="${container.containerStandard eq 'S'}">20'</c:when><c:otherwise>40'</c:otherwise></c:choose>
                            <c:if test="${i.count ne declare.declaContainers.size()}">,</c:if>
                        </c:forEach>
                    </td>
                    <td style="border: 0;border-right: 1px solid;">随附单证<br/>${declare.suifudanValue}</td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td colspan="4">
            标记唛码及备注：${declare.remark}<br/>
            随附单证<br/>${declare.suifudanValue}
        </td>
    </tr>
    <c:if test='${declare.record_id != null}'>
        <tr>
            <td colspan="4">
                <table>
                    <tr>
                        <th style="border: 0;border-bottom: 1px solid;">项号</th>
                        <th style="border: 0;border-bottom: 1px solid;">手册项号</th>
                        <th style="border: 0;border-bottom: 1px solid;">商品编号</th>
                        <th style="border: 0;border-bottom: 1px solid;">商品名称、规格型号</th>
                        <th style="border: 0;border-bottom: 1px solid;">数量及单位</th>
                        <th style="border: 0;border-bottom: 1px solid;">最终目的国(地区)</th>
                        <!-- 						<th style="border: 0;border-bottom: 1px solid;">原产国</th> -->
                        <th style="border: 0;border-bottom: 1px solid;">单价</th>
                        <th style="border: 0;border-bottom: 1px solid;">总价</th>
                        <th style="border: 0;border-bottom: 1px solid;">币制</th>
                        <th style="border: 0;border-bottom: 1px solid;">征免</th>
                    </tr>
                    <c:forEach var="cm" items="${declare.commodities}" varStatus="st">
                        <tr style="cursor:hand" onmousemove="changeTrColor(this)">
                            <td style="border: 0;border-bottom: 1px dashed;">00${st.index+1}</td>
                            <c:choose>
                                <c:when test="${declare.declaration_type eq 'I'}">
                                    <td style="border: 0;border-bottom: 1px dashed;">${cm.contractNumber}</td>
                                </c:when>
                                <c:otherwise>
                                    <td style="border: 0;border-bottom: 1px dashed;">${empty cm.handbook_item_no ? cm.record_id : cm.handbook_item_no}</td>
                                </c:otherwise>
                            </c:choose>
                            <td style="border: 0;border-bottom: 1px dashed;">${cm.code_t}${cm.code_s}</td>
                            <td style="border: 0;border-bottom: 1px dashed;">
                                    ${cm.name}<br/>
                                    ${cm.goods_mode}<br/>
                            </td>
                            <td style="border: 0;border-bottom: 1px dashed;">
                                <c:choose>
                                    <c:when test="${cm.unit == cm.legal_unit}">
                                        ${cm.count}
                                        ${cm.unit} <br/>
                                        ${cm.second_count}
                                        ${cm.second_unit}<br/>
                                    </c:when>
                                    <c:when test="${cm.unit == cm.second_unit}">
                                        ${cm.count}
                                        ${cm.unit} <br/>
                                        ${cm.legal_count}
                                        ${cm.legal_unit}<br/>
                                    </c:when>
                                    <c:when test="${cm.unit != '千克' && cm.legal_unit!= '千克' && cm.second_unit != '千克'}">
                                        ${cm.count}
                                        ${cm.unit} <br/>
                                        ${cm.legal_count}
                                        ${cm.legal_unit}<br/>
                                        ${cm.second_count}
                                        ${cm.second_unit}<br>
                                        ${cm.goods_net_weight} KG
                                    </c:when>
                                    <c:otherwise>
                                        ${cm.count}
                                        ${cm.unit} <br/>
                                        ${cm.legal_count}
                                        ${cm.legal_unit}<br/>
                                        ${cm.second_count}
                                        ${cm.second_unit}<br>
                                    </c:otherwise>
                                </c:choose>
                            </td>
                            <td style="border: 0;border-bottom: 1px dashed;">
                                <c:choose>
                                    <c:when test="${declare.declaration_type eq 'I'}">
                                        &nbsp;&nbsp;${cm.origin_country}
                                        <br/>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        目的国：${cm.destination}
                                    </c:when>
                                    <c:otherwise>
                                        &nbsp;&nbsp;${cm.destination}
                                        <br/>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        原产国：${cm.origin_country}
                                    </c:otherwise>
                                </c:choose>
                            </td>
                                <%-- 							<td style="border: 0;border-bottom: 1px dashed;">${origin_country}</td> --%>
                            <td style="border: 0;border-bottom: 1px dashed;">${cm.unit_price}</td>
                            <td style="border: 0;border-bottom: 1px dashed;">${cm.total_price}</td>
                            <td style="border: 0;border-bottom: 1px dashed;">
                                <br/>
                                    ${cm.currency}</td>
                            <td style="border: 0;border-bottom: 1px dashed;">${cm.levymode}</td>
                        </tr>
                    </c:forEach>
                    <tr>
                        <td colspan="9" align="right" style="border: 0;border-top: 1px dashed;">
                            总值：${declare.total_money }</td>
                    </tr>
                    <tr>
                        <td colspan="9" align="center" style="border: 0;border-top: 1px dashed;">
                            *****以下空白*****
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </c:if>
    <c:if test='${declare.record_id == null}'>
        <tr>
            <td colspan="4">
                <table>
                    <tr>
                        <th style="border: 0;border-bottom: 1px solid;">项号</th>
                        <th style="border: 0;border-bottom: 1px solid;">商品编号</th>
                        <th style="border: 0;border-bottom: 1px solid;">商品名称、规格型号</th>
                        <th style="border: 0;border-bottom: 1px solid;">数量及单位</th>
                        <th style="border: 0;border-bottom: 1px solid;">
                            <c:choose><c:when
                                    test="${declare.declaration_type eq 'I'}">原产国(地区)</c:when><c:otherwise>最终目的国(地区)</c:otherwise></c:choose>
                        </th>
                        <th style="border: 0;border-bottom: 1px solid;">单价</th>
                        <th style="border: 0;border-bottom: 1px solid;">总价</th>
                        <th style="border: 0;border-bottom: 1px solid;">币制</th>
                        <th style="border: 0;border-bottom: 1px solid;">征免</th>
                    </tr>
                    <c:forEach var="cm" items="${declare.commodities}" varStatus="st">
                        <tr>
                            <td style="border: 0;border-bottom: 1px dashed;">00${st.index+1}</td>
                            <td style="border: 0;border-bottom: 1px dashed;">${cm.code_t}${cm.code_s}</td>
                            <td style="border: 0;border-bottom: 1px dashed;">
                                    ${cm.name}<br/>
                                    ${cm.goods_mode}<br/>
                            </td>
                            <td style="border: 0;border-bottom: 1px dashed;">
                                ${cm.count}
                                ${cm.unit} <br/>
                                ${cm.legal_count}
                                ${cm.legal_unit}<br/>
                                ${cm.second_count}
                                ${cm.second_unit}<br>
                            </td>
                            <td style="border: 0;border-bottom: 1px dashed;">
                                <c:choose>
                                    <c:when test="${declare.declaration_type eq 'I'}">
                                        &nbsp;&nbsp;${cm.origin_country}
                                        <br/>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        目的国：${cm.destination}
                                    </c:when>
                                    <c:otherwise>
                                        &nbsp;&nbsp;${cm.destination}
                                        <br/>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        原产国：${cm.origin_country}
                                    </c:otherwise>
                                </c:choose>
                            </td>
                            <td style="border: 0;border-bottom: 1px dashed;">${cm.unit_price}</td>
                            <td style="border: 0;border-bottom: 1px dashed;">${cm.total_price}</td>
                            <td style="border: 0;border-bottom: 1px dashed;">
                                <br/>
                                    ${cm.currency}</td>
                            <td style="border: 0;border-bottom: 1px dashed;">${cm.levymode}</td>
                        </tr>
                    </c:forEach>
                    <tr>
                        <td colspan="9" align="right" style="border: 0;border-top: 1px dashed;">
                            总值：${declare.total_money }</td>
                    </tr>
                    <tr>
                        <td colspan="9" align="center" style="border: 0;border-top: 1px dashed;">
                            *****以下空白*****
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </c:if>

    </tbody>
</table>
<c:if test="${param.v=='3.0'}">
    </body>
    </html>
</c:if>
